﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using BL;
using DA;
using Entities;

namespace ERP
{
    public partial class ToPrintOrder : BaseERPPage
    {
        OrderManager orderManager = new OrderManager();
        OrderItemManager orderItemManager = new OrderItemManager();

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                string productId = Request.QueryString.Get("OrderId");
                if (!string.IsNullOrEmpty(productId))
                {
                    ERP_Orders orderFromDb = orderManager.GetOrder(int.Parse(productId));
                    LabelOrderId.Text = orderFromDb.OrderId.ToString();
                    LabelOrderDate.Text = orderFromDb.CreationDate.ToShortDateString();
                    LabelSupplier.Text = orderFromDb.ERP_Suppliers.Name;
                    LabelReason.Text = orderFromDb.OrderReason;
                    LabelPaymentMethod.Text = orderFromDb.PaymentMethod;
                    ItemsInOrder.DataSourceU = orderItemManager.GetItemsInOrder(int.Parse(productId));
                    ItemsInOrder.DataBind();
                    LabelPrice.Text = orderFromDb.Price.ToString();
                    LabelCreatorName.Text = orderFromDb.ERP_Users.FirstName +" "+ orderFromDb.ERP_Users.LastName;
                }
            }

        }
    }
}